import { mapState } from "vuex";

export const mixinAuth = {
  computed: {
    ...mapState("sp-common/auth", ["isAnonUser"]),
    ...mapState("sp-common/user", ["userInfo"]),
  },
  methods: {
    handleMixinAuth(event, ...params) {
      const authPage = this.$children.filter(
        (v) => v?.templateId === "AUTH_PAGE"
      );
      if (this.isAnonUser || !this.userInfo?.phone) {
        return authPage[0]?.$refs.loginModalRef.open();
      }
      event(...params);
    },
  },
};
